home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 December / PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin / prgmming / dos / asm / uasm_lst.bas < prev    next >
BASIC Source File  |  1984-03-04  |  6KB  |  103 lines

  1. 1  '------------------------------------------------------------------------
  2. 2  '-               UASMLST.BAS    VER 1.0     07/02/83                    -
  3. 3  '-                                                                      -
  4. 4  '-        REMOVES ADDRESSES FROM FILES CREATED FROM DEBUG UN-           -
  5. 5  '-        ASSEMBLE SCRIPT FILES (DOS 2.0 ONLY) AND INSERTS LABELS.      -
  6. 6  '-        A SCRIPT FILE (ASCII PLEASE ) IS CREATED WITH THE             -
  7. 7  '-        DEBUG INSTRUCTIONS (I.E.:                                     -
  8. 8  '-                           U ADR1 ADR2                                -
  9. 9  '-                           U ADR3 ADR4                                -
  10. 10 '-                           Q                                          -
  11. 11 '-        AND THEN PROCESSED AS FOLLOWS FROM THE DOS PROMPT:            -
  12. 12 '-         A>DEBUG D:MYFILE.EXT <SCRIPT >UNASM.TXT                      -
  13. 13 '-        ALL OUTPUT THAT WOULD NORMALLY GO TO THE SCREEN IS PIPED      -
  14. 14 '-        TO THE FILE UNASM.TXT.                                        -
  15. 15 '-                                                                      -
  16. 16 '-        UNASM.TXT IS THEN SUBMITTED TO UASMLST FOR PROCESSING.        -
  17. 17 '-                                                                      -
  18. 18 '-        DEBUG PIPED OUTPUT IS FORMATTED AS FOLLOWS:                   -
  19. 19 '-        POSITION            DATA                                      -
  20. 20 '-        --------            ----                                      -
  21. 21 '-        1 -  4              DEFAULT SEGMENT                           -
  22. 22 '-             5              CONSTANT :                                -
  23. 23 '-        6 -  9              OFFSET VALUE                              -
  24. 24 '-            10              BLANK                                     -
  25. 25 '-       11 - 24              HEX VALUE OF CONTENTS                     -
  26. 26 '-       25 - 32              MNEMONIC                                  -
  27. 27 '-       33 -  -              OPERAND                                   -
  28. 28 '-                                                                      -
  29. 29 '-                                                                      -
  30. 30 '------------------------------------------------------------------------
  31. 100 CLS
  32. 110 KEY OFF
  33. 120 DEFINT A-Z
  34. 130 DIM ADDR.REF$(2000),JUMP$(25)
  35. 140 JUMPNUMBER=21
  36. 150     FOR I = 1 TO JUMPNUMBER
  37. 160         READ JUMP$(I)
  38. 170     NEXT
  39. 180 DATA "JMP ","JMPS","JZ  ","JNZ ","LOOP","CALL","JCXZ","JB  ","JBE ","JNB ","JA  "
  40. 190 DATA "JG  ","JGE ","JL  ","JLE ","JNO ","JPO ","JNS ","JO  ","JPE ","JS  "
  41. 200 '--------------------------------------------
  42. 210 '         GET FILE NAME                     -
  43. 220 '--------------------------------------------
  44. 230 LOCATE 2,7:PRINT "UASMLST VERSION 1.0"
  45. 240 LOCATE 4,12:INPUT "ENTER NAME OF INPUT FILE: ",INPUTFILE$   'DEBUG OUTPUT
  46. 250 LOCATE 5,12:INPUT "ENTER NAME OF OUTPUT FILE: ",OUTPUTFILE$ 'UASMLST OUTPUT
  47. 260 LOCATE 6,12:PRINT "WORKING........."
  48. 270 '--------------------------------------------
  49. 280 '          PARSE FILE                       -
  50. 290 '--------------------------------------------
  51. 300 OPEN INPUTFILE$ FOR INPUT AS #1
  52. 310 OPEN OUTPUTFILE$ FOR OUTPUT AS #2
  53. 320 IF EOF(1) THEN 390
  54. 330 LINE INPUT #1,UNASSEMBLE$:IF LEN(UNASSEMBLE$)<28 THEN 320 ELSE UNASMINSTR$=MID$(UNASSEMBLE$,25,4)
  55. 340 FOR COUNTER = 1 TO JUMPNUMBER:IF UNASMINSTR$<>JUMP$(COUNTER) THEN NEXT:GOTO 320
  56. 350 IF MID$(UNASSEMBLE$,33,1)="[" THEN 320
  57. 360 IF MID$(UNASSEMBLE$,33,3)="FAR" THEN 320
  58. 370 IF MID$(UNASSEMBLE$,37,1)=":" THEN 320
  59. 380 ADDR.REF=ADDR.REF+1:ADDR.REF$(ADDR.REF)=MID$(UNASSEMBLE$,33,4):GOTO 320
  60. 390 CLOSE #1:OPEN INPUTFILE$ FOR INPUT AS #1
  61. 400 LOCATE 20,13:PRINT "SORTING ........."
  62. 410 '---------------------------------------------------
  63. 420 '              SHELL SORT                          -
  64. 430 '---------------------------------------------------
  65. 440 D=2^INT(LOG(ADDR.REF)/LOG(2))-1
  66. 450 FOR COUNTER = 1 TO ADDR.REF-D
  67. 460 IF ADDR.REF$(COUNTER)<=ADDR.REF$(COUNTER+D) THEN 520 ELSE T$=ADDR.REF$(COUNTER+D):ADDR.REF$(COUNTER+D)=ADDR.REF$(COUNTER)
  68. 470 IF COUNTER<=D THEN ADDR.REF$(COUNTER)=T$:GOTO 520
  69. 480 FOR J=COUNTER-D TO 1 STEP -D
  70. 490 IF T$>=ADDR.REF$(J) THEN 510 ELSE ADDR.REF$(J+D)=ADDR.REF$(J)
  71. 500 NEXT J
  72. 510 ADDR.REF$(J+D)=T$
  73. 520 NEXT COUNTER
  74. 530 D=INT(D/2):IF D>0 THEN 450 ELSE COUNTER = 1
  75. 540 IF COUNTER=ADDR.REF THEN 600
  76. 550 IF ADDR.REF$(COUNTER)=ADDR.REF$(COUNTER+1) THEN FOR J = COUNTER TO ADDR.REF:ADDR.REF$(J)=ADDR.REF$(J+1):NEXT:ADDR.REF=ADDR.REF-1 ELSE COUNTER = COUNTER+1
  77. 560 GOTO 540
  78. 570 '-----------------------------------------------------
  79. 580 '-      NOW SORTED, GOT THRU AND INSERT LABELS       -
  80. 590 '----------------------------------------------------
  81. 600 L=1         'L = LABEL REFERENCE
  82. 610 IF NOT EOF(1) THEN 650 ELSE IF L>ADDR.REF THEN 640
  83. 620 PRINT "ERROR: REFERENCED CODE AT ";ADDR.REF$(L);" WAS NOT FOUND."
  84. 630 PRINT "THE FOLLOWING REFERENCE(S) ARE NOT INCLUDED:":FOR COUNTER =L TO ADDR.REF:PRINT ADDR.REF$(COUNTER),:NEXT
  85. 640 CLOSE:END 'OF PROGRAM
  86. 650 LINE INPUT #1,UNASSEMBLE$:IF LEN(UNASSEMBLE$)<28 THEN 610
  87. 660 IF MID$(UNASSEMBLE$,6,4)<ADDR.REF$(L) THEN MID$(UNASSEMBLE$,6,4)="     ":GOTO 710
  88. 670 IF MID$(UNASSEMBLE$,6,4)=ADDR.REF$(L) THEN 690
  89. 680 IF L>ADDR.REF THEN MID$(UNASSEMBLE$,6,4)="     ":GOTO 710 ELSE 620
  90. 690 L$=STR$(L):L$="L"+RIGHT$(L$,LEN(L$)-1)
  91. 700 L$=L$+":"+STRING$(4-LEN(L$)," "):MID$(UNASSEMBLE$,6,5)=L$:L=L+1
  92. 710 UNASMINSTR$=MID$(UNASSEMBLE$,25,4):FOR COUNTER = 1 TO JUMPNUMBER:IF UNASMINSTR$<>JUMP$(COUNTER) THEN NEXT:GOTO 780
  93. 720 IF MID$(UNASSEMBLE$,33,1)="[" THEN 780
  94. 730 IF MID$(UNASSEMBLE$,33,3)="FAR" THEN 780
  95. 740 IF MID$(UNASSEMBLE$,37,1)=":" THEN 780
  96. 750 REF$=MID$(UNASSEMBLE$,33,4):FOR COUNTER = 1 TO ADDR.REF:IF REF$<>ADDR.REF$(COUNTER) THEN NEXT
  97. 760 L$=STR$(COUNTER):L$="L"+RIGHT$(L$,LEN(L$)-1)
  98. 770 MID$(UNASSEMBLE$,33,4)=L$+STRING$(4-LEN(L$)," ")
  99. 780 UNASSEMBLE$=MID$(UNASSEMBLE$,6,5)+" "+RIGHT$(UNASSEMBLE$,LEN(UNASSEMBLE$)-23)
  100. 790 FOR COUNTER = LEN(UNASSEMBLE$) TO 2 STEP -1:IF MID$(UNASSEMBLE$,COUNTER,1)=" " THEN NEXT
  101. 800 UNASSEMBLE$=LEFT$(UNASSEMBLE$,COUNTER)
  102. 810 PRINT UNASSEMBLE$:PRINT #2,UNASSEMBLE$:GOTO 610
  103.